# -*- coding: utf-8 -*-
from lr2 import settings


def i18n_ex(request):
    """
    Context processor for adding language data
    
    Finds the language code from the list of languages
    ​​that matches one of that list items
    """
    from django.utils import translation
    
    languages = ()
    
    for lang in settings.LANGUAGES:
        languages = languages + ((lang[0], translation.ugettext_lazy(lang[1])),)
    
    context_extras = {}
    context_extras['LANGUAGES'] = languages
    context_extras['LANGUAGE_CODE'] = translation.get_language()
    context_extras['LANGUAGE_BIDI'] = translation.get_language_bidi()
    
    return context_extras
